<?php
   require_once("konf.php"); 
   $kask=$yhendus->prepare(
    "SELECT broneering.broneering_id, nimi, telefon, isikukood, mail, liik, kohtadearv, kogus, broneering.algusaeg, broneering.lopuaeg, elamine 
	FROM broneering, klient, ruum, elamine, ruumiliigid 
	WHERE broneering.broneering_id=elamine.broneering_id AND klient.klient_id=broneering.klient_id AND broneering.broneering_id=?");
  
  echo $yhendus->error;
  $kask->bind_result($broneering_id, $nimi, $telefon, $isikukood, $mail,  $liik, $kohtadearv, $kogus, $algusaeg, $lopuaeg, $elamine);
  $kask->bind_param("i", $_REQUEST["broneering_id"]);
  $kask->execute();
  
?>

<!doctype html>
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="admin.css"/>
	<meta charset="utf-8">
  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">
 
  <style>
  #feedback { font-size: 0.6em; }
  #selectable .ui-selecting { background: #FECA40; }
  #selectable .ui-selected { background: #F39814; color: white; }
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 750px; }
  #selectable li { margin: 3px; padding: 1px; float: right; width: 50px; height: 40px; font-size: 2em; text-align: center; }
  </style>
  <script>
 
  </script>
    <title>INFO</title>
  </head>
  
  <body>
  
   <h2 style="text-align:center;">Broneeringu ülevaade</h2>
<a href="admin.php">TAGASI</a>
<table>
	<table border="2" cellpadding="5">
	  <tr>
	    <th>Broneeringu number</th>
	    <th>Nimi</th>
	    <th>Telefon</th>
		<th>Isikukood</th>
		<th>Mail</th>
	    <th>Liik</th>
		<th>Kohtade arv toas</th>
		<th>Tubade arv</th>
		<th>Algusaeg</th>
	    <th>Lõpuaeg</th>
		<th>Elamine</th>
	    
	  </tr>
	<?php
	
	    if($kask->fetch()){
		 echo $yhendus->error;
		 echo "
		     <tr>
			   <td>$broneering_id</td>
			   <td>$nimi</td>
			   <td>$telefon</td>
			   <td>$isikukood</td>
			   <td>$mail</td>
			   <td>$liik</td>
			   <td>$kohtadearv</td>
			   <td>$kogus</td>
			   <td>$algusaeg</td>
			   <td>$lopuaeg</td>
			   <td>$elamine</td>
			 </tr>
		   ";
		}
       $kask->close();
	 ?>
	</table>
	
<table>
	<table border="2" cellpadding="5">
	  <tr>
		<th>Elaniku id</th>
		<th>Broneeringu nr</th>
		<th>Eesnimi</th>
		<th>Perekonnanimi</th>
		<th>Isikukood</th>

		
	    
	  </tr>
<?php
$kask=$yhendus->prepare(
   "SELECT elanikud.elanikud_id, broneering.broneering_id, eesnimi, perekonnanimi, isikukood
	FROM broneering, elanikud, elamine
	WHERE broneering.broneering_id=elanikud.broneering_id AND broneering.broneering_id=elamine.broneering_id AND elamine.broneering_id=elanikud.broneering_id AND broneering.broneering_id=?");
	echo $yhendus->error;
  $kask->bind_result($elanikud_id, $broneering_id, $eesnimi, $perekonnanimi, $isikukood);
  $kask->bind_param("i", $_REQUEST["broneering_id"]);
  echo $yhendus->error; 
  $kask->execute();
  

	    while($kask->fetch()){
		 echo $yhendus->error;
		 echo "
		     <tr>
			   <td>$elanikud_id</td>
			   <td>$broneering_id</td>
			   <td>$eesnimi</td>
			   <td>$perekonnanimi</td>
			   <td>$isikukood</td>
			   

				   ";
		}
		$kask->close();
	 ?>
	 <h2>Tubade määramine:</h2>
	<?php
$kask=$yhendus->prepare(
   "SELECT ruuminr, liik
	FROM ruum, ruumiliigid,elamine, broneering
	WHERE ruumiliigid.ruumiliigid_id=ruum.ruumiliigid_id AND ruumiliigid.ruumiliigid_id=elamine.ruumiliigid_id AND broneering.broneering_id=elamine.broneering_id AND broneering.broneering_id=?");
	echo $yhendus->error;
  $kask->bind_result($ruuminr, $liik);
  $kask->bind_param("i", $_REQUEST["broneering_id"]);
  echo $yhendus->error; 
  $kask->execute();
  
	while($kask->fetch()){
	echo $yhendus->error;
	echo "
		<td><input type='submit' name='ruumikas' value='$ruuminr'/></td>
			
		";
	}
require("abikas2.php");
$kask->close();
  if(isSet($_REQUEST["ruumilisamine"])){
    lisaruum($_REQUEST["ruuminr"]);
    header("Location: info.php");
    exit();
  }
	 ?> 
<form action="info.php">
     <h2>Ruumi lisamine</h2>
     <dl>
       <dt>Ruuminr:</dt>
       <dd><?php
         echo looRippMenyy("SELECT ruuminr FROM ruum, ruumiliigid, elamine, broneering WHERE ruumiliigid.ruumiliigid_id=ruum.ruumiliigid_id AND ruumiliigid.ruumiliigid_id=elamine.ruumiliigid_id AND broneering.broneering_id=elamine.broneering_id", 
                           "ruuminr");
       ?>
       </dd>
     </dl>
     <input type="submit" name="ruumilisamine" value="Lisa ruum" />
	</table>
	

  </body>
</html>